﻿@model AlbumDetailsVm
    @{const string quantity = "quantity";
        }
<h2>@Model.Title</h2>

<p>
    <img alt="@Model.Title" src="@Model.ArtUrl" />
</p>

<div id="album-details">
    <p>
        <em>Genre:</em>
        @Model.Genre
    </p>
    <p>
        <em>Artist:</em>
        @Model.Artist
    </p>
    <p>
        <em>Price:</em>
        @Model.Price
    </p>
    <p class="button">
        <input type="text" placeholder="Enter quantity" id="@quantity"/>    
        @(Html.When(JqueryBind.Click)
              .Do()
              .AjaxPost(Url.Action("AddItem", "Cart", new
                                                          {
                                                                  AlbumId = Model.Id, 
                                                                  Quantity = Selector.Jquery.Id(quantity)
                                                          }))
              .OnBegin(dsl => dsl.Self().Core().Break.If(builder => builder.Not.Confirm("Are you sure add album {0} to cart ?".F(Model.Title))))
              .OnSuccess(dsl => dsl.With(selector => selector.Id(IncMusicStoreSelector.DefaultDialogId)).JqueryUI().Dialog.Close())
              .AsHtmlAttributes()
              .ToButton("Add to cart"))           
    </p>
</div>